package com.overlord.im.commons.message;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @ClassName MessageEncoder
 * @Author wuwei
 * @Description NONE
 * @Date 2020/5/29 17:53
 **/
public class MessageEncoder extends MessageToByteEncoder<OverlordImMessage> {

    private Protocol protocol;

    public MessageEncoder(Protocol protocol) {
        this.protocol = protocol;
    }

    @Override
    protected void encode(ChannelHandlerContext ctx, OverlordImMessage msg, ByteBuf out) throws Exception {
        protocol.encode(out, msg);
    }
}
